
// const fs = require('fs');
// let data = {
//     id: "0",
//     age: "20"
// }
// // data = JSON.stringify(data)
// var all =fs.writeFileSync("./data.json")
// all = all.tostring()
// all = JSON.parse(all)
// console.log(all)
var express = require('express')
var app = express()
let fs = require('fs');
let all = fs.readFileSync("./data.json");
all = all.toString()
all = JSON.parse(all)
// console.log(all);

app.use((req, res, next) => {
    res.setHeader("Content-Type", "text/html; charset=utf-8")
    res.setHeader("Access-Control-Allow-Origin", "*")
    next()
})
app.get("/abbooks", function (req, res) {
    res.json({
        code: 0,
        msg: "获取所有数据成功",
        data: all
    })
})
// 3启动 web 服务器
app.listen(3000, () => {
    console.log('启动服务；http://127.0.0.1:3000')
})